package com.railway.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.railway.service.AdminService;
import com.railway.service.SuggestionsService;
import com.railway.service.UserService;
import com.railway.service.impl.AdminServiceImpl;
import com.railway.service.impl.SuggestionsServiceImpl;
import com.railway.service.impl.UserServiceImpl;
/**
 * @author 
 *批量删除（逻辑）
 */
@WebServlet("/DelBatchLcu.do")
public class DelBatchLcuServlet extends HttpServlet{

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		resp.setCharacterEncoding("UTF-8");
		resp.setContentType("application/json");
		req.setCharacterEncoding("UTF-8");
		AdminService admin = new AdminServiceImpl();
		String[] adminId = req.getParameterValues("dataId");
		int[] adminIds = new int[adminId.length];
		if(adminIds.length == 0) {
			return ;
		}
		int msg;
		for (int i = 0; i < adminId.length; i++) {
			adminIds[i] = Integer.parseInt(adminId[i]);
			msg = admin.deleteLoseCreditDao(adminIds[i]);
			if(msg == 1) {
				resp.getWriter().print("success");
			}
		}
	}
	
}
